<?php 
$dbhost='127.0.0.1';
$dbuser='root';
$dbpwd ='song@491497047';
$dbName='email';

function getIp()
{
    
    if(!empty($_SERVER["HTTP_CLIENT_IP"]))
    {
        $cip = $_SERVER["HTTP_CLIENT_IP"];
    }
    else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
    {
        $cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
    }
    else if(!empty($_SERVER["REMOTE_ADDR"]))
    {
        $cip = $_SERVER["REMOTE_ADDR"];
    }
    else
    {
        $cip = '';
    }
    preg_match("/[\d\.]{7,15}/", $cip, $cips);
    $cip = isset($cips[0]) ? $cips[0] : 'unknown';
    unset($cips);
    
    return $cip;
}
function get_os() {
    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
        $os = $_SERVER['HTTP_USER_AGENT'];
        if (preg_match('/win/i', $os)) {
            $os = 'Windows';
        } else if (preg_match('/mac/i', $os)) {
            $os = 'MAC';
        } else if (preg_match('/linux/i', $os)) {
            $os = 'Linux';
        } else if (preg_match('/unix/i', $os)) {
            $os = 'Unix';
        } else if (preg_match('/bsd/i', $os)) {
            $os = 'BSD';
        } else {
            $os = 'Other';
        }
        return $os;
    } else {
        return 'unknow';
    }
}
function getbrowser() {
    global $_SERVER;
    $agent  = $_SERVER['HTTP_USER_AGENT'];
    $browser  = '';
    $browser_ver  = '';
    
    if (preg_match('/OmniWeb\/(v*)([^\s|;]+)/i', $agent, $regs)) {
        $browser  = 'OmniWeb';
        $browser_ver   = $regs[2];
    }
    
    if (preg_match('/Netscape([\d]*)\/([^\s]+)/i', $agent, $regs)) {
        $browser  = 'Netscape';
        $browser_ver   = $regs[2];
    }
    
    if (preg_match('/safari\/([^\s]+)/i', $agent, $regs)) {
        $browser  = 'Safari';
        $browser_ver   = $regs[1];
    }
    
    if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs)) {
        $browser  = 'Internet Explorer';
        $browser_ver   = $regs[1];
    }
    
    if (preg_match('/Opera[\s|\/]([^\s]+)/i', $agent, $regs)) {
        $browser  = 'Opera';
        $browser_ver   = $regs[1];
    }
    
    if (preg_match('/NetCaptor\s([^\s|;]+)/i', $agent, $regs)) {
        $browser  = '(Internet Explorer ' .$browser_ver. ') NetCaptor';
        $browser_ver   = $regs[1];
    }
    
    if (preg_match('/Maxthon/i', $agent, $regs)) {
        $browser  = '(Internet Explorer ' .$browser_ver. ') Maxthon';
        $browser_ver   = '';
    }
    if (preg_match('/360SE/i', $agent, $regs)) {
        $browser       = '(Internet Explorer ' .$browser_ver. ') 360SE';
        $browser_ver   = '';
    }
    if (preg_match('/SE 2.x/i', $agent, $regs)) {
        $browser       = '(Internet Explorer ' .$browser_ver. ') 搜狗';
        $browser_ver   = '';
    }
    
    if (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs)) {
        $browser  = 'FireFox';
        $browser_ver   = $regs[1];
    }
    
    if (preg_match('/Lynx\/([^\s]+)/i', $agent, $regs)) {
        $browser  = 'Lynx';
        $browser_ver   = $regs[1];
    }
    
    if(preg_match('/Chrome\/([^\s]+)/i', $agent, $regs)){
        $browser  = 'Chrome';
        $browser_ver   = $regs[1];
        
    }
    
    if ($browser != '') {
        return $browser.' '.$browser_ver;
    } else {
        return 'unknow browser';
    }
}


?>